from random import randint
from tkinter import *
import time

tk=Tk()
canvas=Canvas(tk,width=500,height=250)#创建画布
canvas.pack()
id1=canvas.create_oval(10,50,60,100,fill='yellow',outline='gray')#创建模型
id2=canvas.create_oval(10,150,60,200,fill='green')
# for x in range(0,80):
#     canvas.move(id1,5,0)
#     canvas.move(id2,5,0)
#     tk.update()
#     time.sleep(0.05)
for x in range(0,100):
    if randint(1,100)>50:
        canvas.move(id2,5,0)
    else:canvas.move(id1,5,0)
    tk.update()
    time.sleep(0.05)